The present invention is related to computer software and more specifically to computer software for generating identifiers.
A database may be used to store information arranged in multiple records. Many conventional databases allow the database programmer to request the database to generate a serial number or other identifier for each record in the database. The database generates a number for the record that is a certain number higher than the number of the last record. For example, the database may be programmed so that each record receives an identifier that is one higher than the identifier generated for the prior record. Identifiers are not limited to numbers: they may actually contain a combination of letters and numbers.
Some databases allow application programs to direct some or all of their operations. The application programs use the database for storage and retrieval of information for example, using conventional SQL commands or other similar commands. This speeds development of the applications because the functionality associated with the database need not be recreated by each application.
A central database that supports multiple applications can solve difficult problems. For example, it may be desirable to ensure that a customer who initiates two transactions over the Internet is assigned two transaction numbers, with the transaction number of the transaction that was initiated earliest being lower than the transaction number of the later transaction. Such an arrangement may be required by regulatory authorities, such as the U.S. Securities and Exchange Commission. Because many independent applications, each running on separate web servers, may be used to process the transactions, a central database can supply the identifiers in the proper order. The web servers can request the central database to create a new record at the time each transaction is initiated. The central database issues an identifier to each record as it is created. The database stores the identifier in the database record for use as a record identifier, and supplies the identifier to the application. The identifier is supplied to the user of the application for use as a transaction number. Because the central database supplies the identifiers for all of the web servers, a customer who requests a transaction on one web server and then requests a second transaction on a second web server is assured of receiving identifiers matching the order of the time of initiation of the transaction.
The order of the identifiers need not correspond to initiation of the transaction: if it is desirable that the order of the identifiers match another event, such as submission of an order, each database record can be created at that time to ensure the order of the identifiers matches the order of the events.
In addition to providing identifiers, a database can help protect the data it stores from corruption. For example, databases create logs on a hard disk that can be used to roll back the database to a state at a particular point in time, undoing any changes made after that point in time. If a problem is detected, the roll back facilities of the database may be used to return the database to a prior state that did not contain the problem. The use of the disk means that even if volatile storage such as memory is lost, for example during a power failure, the database may be rolled back to the time just prior to the time at which the power failed, and restarted with only a minor loss of data.
When a database that creates one or more hard disk logs is used to generate identifiers, problems may result. Because of the time it takes to create the disk records that can be used to roll back one or more transactions, using a database to provide the identifier of each record can cause a delay in the operation of the application programs because the database will require a prior record to be stored to disk before the database can issue a new identifier based on the number of the prior record. If identifiers are requested faster than the database can store the logs onto the disk, the speed of operation of the application programs may be reduced.
What is needed is a system and method that can rapidly provide an ordered set of identifiers for database records.
A system and method generates and stores identifiers in memory at memory speeds, then provides each identifier generated to one or more of several application programs. The system and method may generate the identifiers as part of a conventional operating system of a computer system, allowing a serial number to be obtained using an API call to the operating system. The identifiers are provided to, and stored in, a database as the applications require. If the system fails, for example, due to a power failure, the database may be requested to provide the latest identifier stored, and the method and apparatus generate subsequent serial numbers using this latest identifier.